
#include <iostream>
#include "fun.h"

int main()
{
    std::cout << "Test cuda Prefix Sum" << std::endl;
    {
    
    int N = 1873*7192;

    hs::raster::RasterData<float> raster(N, 1);
    for (int i = 0; i < N; ++i) {
        raster(i, 0) = 1;
    }

    hs::raster::RasterData<float> prefix_sum;
    getPrefixOpenSum(raster, prefix_sum);

    printf("Open Prefix Sum[0...9]:\n");
    for (int i = 0; i < 10; ++i) {
        printf("%10.0f", prefix_sum(i, 0));
    }
    printf("\n");
    printf("Refer value[0...9]:\n");
    for (int i = 0; i < 10; ++i) {
        printf("%10.0f", (float)i);
    }
    printf("\n");
    
    printf("Open Prefix Sum[end-9...end]:\n");
    for (int i = N - 10; i < N; ++i) {
        printf("%10.0f", prefix_sum(i, 0));
    }
    printf("\n");
    printf("Refer value[end-9...end]:\n");
    for (int i = N - 10; i < N; ++i) {
        printf("%10.0f", (float)i);
    }
    printf("\n");

    }

    std::cout << "Test cuda Index Mask: " << std::endl;
    {

    int size_x = 5;
    int size_y = 6;
    hs::raster::RasterData<float> datas(size_x, size_y);
    for (int y = 0; y < size_y; ++y) {
        for (int x = 0; x < size_x; ++x) {
            datas(x, y) = x + y;
        }
    }
    std::cout << "datas:\n";
    printmat(datas.view());

    float thre = 5;
    hs::raster::RasterData<float> elems;
    extractElements(datas, thre, elems);
    std::cout << "Greater than " << thre << ": \n";
    printmat(elems.view());

    }

    std::cout << "Done!" << std::endl;
    return 0;
}
